#include "StringUtil.h"

int contarCaracteres(char * cadena, char sep)
{ 
  unsigned int i,cant;
  cant = 0;
  for (i = 0; i < strlen(cadena); i++)
  {
      if (cadena[i] == sep) {cant++;}
  }
  return(cant);
}

void ltrim(char * cadena, char sep)
{
 unsigned int i;
 if (cadena[0] == sep)
 {  
     for (i=1; i< strlen(cadena); i++)
     {
       cadena[i-1] = cadena[i];
     }
     cadena[i-1] = '\0';
 }

}


void rtrim(char * cadena, char sep)
{
    unsigned int i;
    i=strlen(cadena);
    if (cadena[i-2] == sep)
    {
           cadena[i-2] = '\0';
    }
}


void prepareLine(char* line){
	;
}

void skipBlanks(char** str){
	
	while(**str){

		if ( isBlank(**str) ){
			(*str)++;
		} else {
			break;
		}

	}
	
}

int isBlank(char c){
	return ( isspace( (unsigned char) c ) 
			 || c == '\n' 
			 || c == '\r' ); 
	//TODO SACAR ESO
	
	
}


int getSubstringSize(char* str,char lim2){
	
	int result = 0; 
	while (str && (*str) != lim2  ){
		result++;
		str++;
	}
	return result;
}